/**
 * Project Name:gmall-store-web-manage-pc
 * File Name:RequestUtil.java
 * Package Name:com.gfresh.mall.util
 * Date:2016年4月12日下午1:48:28
 * Copyright (c) 2016, 上海极鲜网电子商务有限公司. All Rights Reserved.
 *
*/

package cn.com.uthink.util;

import java.util.UUID;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * ClassName:RequestUtil <br/>
 * @Description: TODO 处理http请求的request共有操作
 * Date:     2016年4月12日 下午1:48:28 <br/>
 * @author   admin
 * @version  2.0.0
 * @since   jdk1.8
 */
public class RequestUtil {

	/**
	 * 
	 * getUserId:从session中获取用户的id <br/> 
	 * @param request
	 * @return
	 */
	public static String getUserId(HttpServletRequest request){

	  	HttpSession session = request.getSession(true);
	  	if(session.getAttribute("userId")!=null){
	  		return session.getAttribute("userId").toString();
	  	}
	  	else{
	  		return "88888888";
	  	}
	  
	}
	
	/**
	 * 
	 * getUserId:从session中获取用户的id <br/> 
	 * @param request
	 * @return
	 */
	public static String getStoreId(HttpServletRequest request){

	  	HttpSession session = request.getSession(true);
	  	if(session.getAttribute("storeId")!=null){
	  		return session.getAttribute("storeId").toString();
	  	}
	  	else{
	  		return "f750124d-0ab1-405d-80d6-6e9fe07ef5cf";
	  	}
	  
	}
	
	public static String getUUID(){
		 return UUID.randomUUID().toString();
	}
	
	public static void main(String[] args) {
		System.out.println(getUUID().length());
	}
}

